﻿using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.DependencyInjection;

namespace CommonUtils
{
    public class FilterOfAuthorization : IAuthorizationFilter
    {
        public void OnAuthorization(AuthorizationFilterContext context)
        {
            (ReflectionUtil.GetSenderClassName() + "." + ReflectionUtil.GetSenderMethodName()
                + " FilterOfAuthorization: "
          + context.HttpContext.Request.Path).Print();
        }

        public static void AddTo(IServiceCollection services)
        {
            services.AddMvc(options => options.Filters.Add<FilterOfAuthorization>());
        }
    }
}
